﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
    public class nhacc_DAL:ketnoi
    {
        public bool NhaCC_them(VO.nhacc_vo data)
        {
            try
            {
                using (SqlCommand dbCmd = new SqlCommand("nhacc_Insert", GetConnection()))
                {
                    dbCmd.CommandType = CommandType.StoredProcedure;
                    dbCmd.Parameters.Add(new SqlParameter("@DiaChi", data.Diachi));
                    dbCmd.Parameters.Add(new SqlParameter("@SDT", data.Sdt));
                    dbCmd.Parameters.Add(new SqlParameter("@TenNCC", data.Tenncc));
                    dbCmd.ExecuteNonQuery();
                }
            }
            catch
            {

            }

            return true;
        }
        public bool NhaCC_sua(VO.nhacc_vo data)
        {
            using (SqlCommand dbCmd = new SqlCommand("nhacc_Update", GetConnection()))
            {
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@DiaChi", data.Diachi));
                dbCmd.Parameters.Add(new SqlParameter("@SDT", data.Sdt));
                dbCmd.Parameters.Add(new SqlParameter("@TenNCC", data.Tenncc));
                dbCmd.ExecuteNonQuery();
            }

            return true;
        }
        public bool NhaCC_xoa(VO.nhacc_vo data)
        {
            using (SqlCommand dbCmd = new SqlCommand("nhacc_Delete", GetConnection()))
            {
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@MaNCC", data.Mancc));
                dbCmd.ExecuteNonQuery();
            }

            return true;
        }
        public DataTable NhaCC_xem()
        {
            DataTable dt = new DataTable();
            using (SqlCommand dbCmd = new SqlCommand("nhacc_SelectAll", GetConnection()))
            {
                SqlDataAdapter da = new SqlDataAdapter(dbCmd);
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.ExecuteNonQuery();
                da.Fill(dt);
            }

            return dt;
        }
        public DataTable NhaCC_tkten(VO.nhacc_vo data)
        {
            DataTable dt = new DataTable();
            using (SqlCommand dbCmd = new SqlCommand("nhacc_GetByTenNCC", GetConnection()))
            {
                SqlDataAdapter da = new SqlDataAdapter(dbCmd);
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@TenNCC", data.Tenncc));
                dbCmd.ExecuteNonQuery();
                da.Fill(dt);
            }

            return dt;
        }
        public DataTable NhaCC_tkma(VO.nhacc_vo data)
        {
            DataTable dt = new DataTable();
            using (SqlCommand dbCmd = new SqlCommand("nhacc_GetByID", GetConnection()))
            {
                SqlDataAdapter da = new SqlDataAdapter(dbCmd);
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@MaNCC", data.Mancc));
                dbCmd.ExecuteNonQuery();
                da.Fill(dt);
            }

            return dt;
        }
    }
}
